const { extend, Toast } = require('../../zanui/index')
import { HOST } from '../../config/apiConfig.js'
import { obj2Form } from '../../utils/util.js'

//获取应用实例
const app = getApp()

Page(extend({}, Toast, {
  data: {
    hotelLevelData: [],
  },
  onLoad: function () {
    wx.setNavigationBarTitle({
      title: '酒店星级管理'
    })
  },
  onShow: function () {
    this.getHotelLevelData()
  },
  getHotelLevelData: function () {
    const _self = this
    wx.request({
      url: HOST + '/v1/hotelLevel',
      method: 'GET',
      success: (res) => {
        const data = res.data.data
        wx.stopPullDownRefresh()
        _self.setData({
          hotelLevelData: data
        })
      }
    })
  },
  // 添加按钮
  btnAdd: function () {
    wx.navigateTo({
      url: '../hotelLevelEdit/hotelLevelEdit',
    })
  },
  // 下拉刷新
  onPullDownRefresh() {
    this.getHotelLevelData()
  },
  editHotelLevel(event) {
    const id = event.currentTarget.dataset.id
    wx.navigateTo({
      url: '../hotelLevelEdit/hotelLevelEdit?id=' + id,
    })
  }
}))
